1
|
|
|
var assert = require('chai').assert, |
2
|
|
|
GedcomX = require('../'); |
3
|
|
|
|
4
|
|
|
describe('OnlineAccount', function(){ |
5
|
|
|
|
6
|
|
|
it('Create plain', function(){ |
7
|
|
|
assert.instanceOf(new GedcomX.OnlineAccount(), GedcomX.OnlineAccount, 'An instance of OnlineAccount is not returned when calling the constructor with new.'); |
8
|
|
|
assert.instanceOf(GedcomX.OnlineAccount(), GedcomX.OnlineAccount, 'An instance of OnlineAccount is not returned when calling the constructor without new.'); |
9
|
|
|
}); |
10
|
|
|
|
11
|
|
|
it('Create with JSON', function(){ |
12
|
|
|
var account = GedcomX.OnlineAccount({ |
13
|
|
|
accountName: 'jimbo', |
14
|
|
|
serviceHomepage: { |
15
|
|
|
resource: 'http://service/home' |
16
|
|
|
} |
17
|
|
|
}); |
18
|
|
|
assert.equal(account.getAccountName(), 'jimbo'); |
19
|
|
|
assert.equal(account.getServiceHomepage().getResource(), 'http://service/home'); |
20
|
|
|
}); |
21
|
|
|
|
22
|
|
|
it('Create with mixed data', function(){ |
23
|
|
|
var account = GedcomX.OnlineAccount({ |
24
|
|
|
accountName: 'jimbo', |
25
|
|
|
serviceHomepage: GedcomX.ResourceReference({ |
26
|
|
|
resource: 'http://service/home' |
27
|
|
|
}) |
28
|
|
|
}); |
29
|
|
|
assert.equal(account.getAccountName(), 'jimbo'); |
30
|
|
|
assert.equal(account.getServiceHomepage().getResource(), 'http://service/home'); |
31
|
|
|
}); |
32
|
|
|
|
33
|
|
|
it('Build', function(){ |
34
|
|
|
var account = GedcomX.OnlineAccount() |
35
|
|
|
.setAccountName('jimbo') |
36
|
|
|
.setServiceHomepage(GedcomX.ResourceReference().setResource('http://service/home')); |
37
|
|
|
assert.equal(account.getAccountName(), 'jimbo'); |
38
|
|
|
assert.equal(account.getServiceHomepage().getResource(), 'http://service/home'); |
39
|
|
|
}); |
40
|
|
|
|
41
|
|
|
it('toJSON', function(){ |
42
|
|
|
var data = { |
43
|
|
|
accountName: 'jimbo', |
44
|
|
|
serviceHomepage: { |
45
|
|
|
resource: 'http://service/home' |
46
|
|
|
} |
47
|
|
|
}, account = GedcomX.OnlineAccount(data); |
48
|
|
|
assert.deepEqual(account.toJSON(), data); |
49
|
|
|
}); |
50
|
|
|
|
51
|
|
|
it('constructor does not copy instances', function(){ |
52
|
|
|
var obj1 = GedcomX.OnlineAccount(); |
53
|
|
|
var obj2 = GedcomX.OnlineAccount(obj1); |
54
|
|
|
assert.strictEqual(obj1, obj2); |
55
|
|
|
}); |
56
|
|
|
|
57
|
|
|
}); |